class Solution {
    public String reverseWords(String s) {
        return Arrays.stream(s.split(" "))
                     .map(i -> reverseStr(i))
                     .collect(Collectors.joining(" "));
    }
    private String reverseStr(String s) {
        char[] a = s.toCharArray();
        for (int i = 0, j = a.length - 1; i < j; i++, j--) {
            char tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        return new String(a);
        // StringBuilder sb = new StringBuilder();
        // for (int i = s.length() - 1; i >= 0; i--) sb.append(s.charAt(i));
        // return sb.toString();
    }
}
